package com.yz.android18_tweenanimation;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private Context mContext = this;
    private ImageView imageView_main;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main,menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch(item.getItemId()){
            case R.id.action_intent:
                //IntentV快捷键
                Intent view = new Intent();
                view.setAction(Intent.ACTION_VIEW);
                //view.setData(Uri.parse());
                startActivity(view);
                break;

        }
        return super.onOptionsItemSelected(item);
    }

    private void initView() {
        imageView_main = (ImageView) findViewById(R.id.imageView_main);
    }

    public void clickView(View view) {
        switch (view.getId()) {
            case R.id.button_alpha:
                imageView_main.startAnimation(AnimationUtils.loadAnimation(mContext,R.anim.alpha));
                break;
            case R.id.button_rotate:
                imageView_main.startAnimation(AnimationUtils.loadAnimation(mContext,R.anim.rotate));
                break;
            case R.id.button_scale:
                imageView_main.startAnimation(AnimationUtils.loadAnimation(mContext,R.anim.scael));
                break;
            case R.id.button_translate:
                imageView_main.startAnimation(AnimationUtils.loadAnimation(mContext,R.anim.translate));
                break;
            case R.id.button_set:
                break;

        }

    }

    public void clickImageView(View view) {
        switch(view.getId()){
            case R.id.imageView_main:
                Toast.makeText(MainActivity.this, "你点我了", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
